#pragma once

#ifndef LEVEL_H
#define LEVEL_H

#include <string>
#include "LevelSquare.h"
#include "Entity.h"
#include "Collision.h"

class Level
{
private:
	int m_width;
	int m_height;
	int m_ID;
	D3DVIEWPORT9 m_viewport;
	D3DXVECTOR3 m_initOffset;
	D3DXVECTOR3 m_offset;
	D3DXVECTOR3 m_startPoint;
	D3DXVECTOR3 m_endPoint;
	TileSet* m_tileset;
	LevelSquare** m_squares;
public:
	Level(int width, int height, D3DVIEWPORT9 viewport, TileSet* tileset, 
		  D3DXVECTOR3 startPoint, D3DXVECTOR3 endPoint, D3DXVECTOR3 offset);
	~Level();
	LevelSquare getSquare(int x, int y) { return m_squares[x][y]; }
	void clearSquare(int x, int y) { m_squares[x][y].setVisible(false); }
	void setSquare(int x, int y, LevelSquare square);
	void draw(ID3DXSprite* sprite);
	D3DXVECTOR3 checkCollision(Entity* entity, BoundingBox& bounds, D3DXVECTOR3 movement);
	static Level* createLevel(TileSet* tileSet, std::string path,
		D3DVIEWPORT9 viewport, D3DXVECTOR3 startPoint, D3DXVECTOR3 endPoint, D3DXVECTOR3 offset);
	// Getters and setters.
	int getWidth() { return m_width; }
	void setWidth(int width) { m_width = width; }
	int getHeight() { return m_height; }
	void setHeight(int height) { m_height = height; }
	int getID() const { return m_ID; }
	void setID(int ID) { m_ID = ID; }
	D3DVIEWPORT9 getViewport() { return m_viewport; }
	void setViewport(D3DVIEWPORT9 viewport) { m_viewport = viewport; }
	
	D3DXVECTOR3 getOffset() { return m_offset; }
	
	D3DXVECTOR3 getInitOffset() { return m_initOffset; }

	D3DXVECTOR3 getStartPoint() { return m_startPoint; }

	D3DXVECTOR3 getEndPoint() {	return m_endPoint; }

	void setOffset(D3DXVECTOR3 offset) { m_offset = offset; }
	TileSet* getTileSet() { return m_tileset; }
	void setTileSet(TileSet* tileSet) { m_tileset = tileSet; }
};

#endif